<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="js/public.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/font.js"></script>
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/ui.css">
    <title></title>
    <!-- 登录 -->
</head>
<body>
<div class="view-container login" style="overflow:auto;background: #615FD6;">
    <div class="top-public">
        <span class="public-center">账户登录</span>
        <!--<img src="images/left_icon.png" alt="" class="public-left">-->
    </div>
    <img src="images/logo1.png" alt="" class="logo">
    <div class="center-box">
        <ul>
            <li><input type="text" name="" id="Phone" placeholder="请输入手机号"></li>
            <li><input type="password" name="" id="Pass" placeholder="请输入密码"><img src="images/closemima.png" alt="" class="closemima"></li>
        </ul>
        <div class="login-btn" onclick="signIn()">登录</div>
        <div class="other">
            <span class="line-one"></span>
            <a href="registerFail.html">新用户注册</a>
            <span class="line-two"></span>
            <a href="login_forget.html">忘记密码</a>
            <span class="line-one"></span>
        </div>
    </div>
    <div class="copyright">
        <p>邦伲德（上海）网络科技有限公司</p>
        <p>Copyright © 2018 bonnidee. All Rights Reserved.</p>
    </div>
</div>
</body>
<script>
$('.public-left').click(function(){
    window.history.go(-1);
});
var mima_btn = 0;
$('.closemima').click(function(){
    if(mima_btn == 0 ){
        mima_btn = 1;
        $('.closemima').attr('src','images/xianshimima.png');
        $('.closemima').css({'height':'0.19rem','width':'0.25rem'});
        $('#Pass').attr('type','text');
    } else {
        mima_btn = 0;
        $('.closemima').attr('src','images/closemima.png');
        $('.closemima').css({'height':'0.22rem','width':'0.25rem'});
        $('#Pass').attr('type','password');
    }
});
</script>
<script>

    $(function() {
        sessionStorage.clear();
        localStorage.clear();
        //判断是否在微信端
        // isWeChat();
    });
    function isWeChat() {
        $.ajax({
            url: url() + 'api/admin/isWeChat', //请求的url地址
            dataType: "JSON", //返回格式为json
            async: true, //请求是否异步，默认为异步，这也是ajax重要特性
            type: "GET", //请求方式
            success: function (data) {
                //请求成功时处理
                if(data.status == 1){
                    // console.log(data.msg);
                }if (data.status == -1) {
                    console.log(data.msg);
                    window.location.href = 'weixin.html';
                }
            }
        });
    }
    //提交登录信息
    function signIn() {
        var mobile = $('#Phone').val();
        var Password = $('#Pass').val();
        var myreg = /^1[3|4|5|7|8][0-9]{9}$/;
        if (mobile == '') {
            alert('手机号不能为空');
            return false;
        } else if (!myreg.test(mobile)) {
            alert('请输入正确的手机号');
            return false;
        } else if (Password == '') {
            alert('密码不能为空');
            return false;
        } else {
            $.ajax({
                url: url() + 'api/admin/login', //请求的url地址
                dataType: "JSON", //返回格式为json
                async: true, //请求是否异步，默认为异步，这也是ajax重要特性
                type: "POST", //请求方式
                data:{
                    mobile:mobile,
                    password:Password,
                },
                success: function (data) {
                    //请求成功时处理
                    if(data.status == 1){
                        // console.log(data.result);
                        sessionStorage.setItem("userId",data.result.user_id);
                        localStorage.setItem("userID",data.result.user_id);
                        window.location.href = 'index.html';
                    }if (data.status == -1) {
                        alert(data.msg);
                        return false;
                    }
                }
            });
        }
    }
</script>

</html>






